<%-- 
    Document   : services
    Created on : Mar 16, 2014, 11:16:40 PM
    Author     : kenn
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>

<c:set scope="request" var="title" value="Home Page"/>

<sql:setDataSource user="root" password="" driver="com.mysql.jdbc.Driver"
                   url="jdbc:mysql://localhost/bonix"/>

<c:set var="startFromRecNo" value="0"/>
<c:set var="display" value="all"/>

<c:if test="${param.start != null}">
    <c:set var="startFromRecNo" value="${param.start}"/>
</c:if>

<sql:query var="serviceProviders" maxRows="8" startRow="${startFromRecNo}">
    SELECT username from accounts where acctype = 'SP';
</sql:query>

<!DOCTYPE html>
<html>
    <jsp:include page="head.jsp"/>

    <body>
        <jsp:include page="header.jsp"/>

        <div class="row">
            <div class="container">
                <div class="content row">

                    <div class="containerService">

                        <div class="panel-heading">
                            <ul class="list-unstyled list-inline navClient navClient-pills text-center">
                                <li><a href="services.jsp?serviceType=All">ALL</a></li>
                                <li><a href="sortServiceProviders.jsp?serviceType=E">ELECTRICAL SERVICES</a></li>						
                                <li><a href="sortServiceProviders.jsp?serviceType=P">PLUMBING SERVICES</a></li>
                                <li><a href="sortServiceProviders.jsp?serviceType=C">CARPENTRY SERVICES</a></li>
                            </ul>
                        </div>

                        <c:if test="${startFromRecNo > 0}">
                            <c:url var="prevURL" value="services.jsp">
                                <c:param name="start" value="${startFromRecNo - 8}"></c:param>
                            </c:url>
                            <br><a href="${prevURL}">Previous</a>
                        </c:if>

                        <c:if test="${serviceProviders.limitedByMaxRows}">
                            <c:url var="nextURL" value="services.jsp">
                                <c:param name="start" value="${startFromRecNo + 8}"></c:param>
                            </c:url>
                            <br><a href="${nextURL}">Next</a>
                        </c:if>

                        <div class="panel-body">
                            <br><hr><br>
                            <ul class="thumbnails">
                                <c:forEach var="serviceProviders" items="${serviceProviders.rows}">
                                    <li class="adjusted-thumbnails">
                                        <a href="serviceProfile.jsp?serviceProvider=${serviceProviders.username}" class="thumbnail" id="services">
                                            <img alt="${username.name}" src="images/serviceProvidersImages/${serviceProviders.username}.jpg">
                                            <p> ${serviceProviders.username} </p>
                                            <sql:query var='service'>
                                                SELECT service from serve where userid=?;
                                                <sql:param value="${serviceProviders.username}"/>
                                            </sql:query>
                                            <c:forEach var="service" items="${service.rows}">
                                                <c:if test="${service.service=='C'}">
                                                    <p>Carpenter</p>
                                                </c:if>
                                                <c:if test="${service.service=='E'}">
                                                    <p>Electrician</p>
                                                </c:if>
                                                <c:if test="${service.service=='P'}">
                                                    <p>Plumber</p>
                                                </c:if>
                                            </c:forEach>

                                        </a>
                                    </li>  
                                    
                                </c:forEach>
                            </ul>
                        </div><!-- END panel-body -->

                    </div><!-- END containerService -->

                </div><!-- END CONTENT CONTENT ROW -->
            </div><!-- END CONTAINER -->
        </div><!-- END ROW -->

        <jsp:include page="footer.jsp"/>               
                
    </body>
</html>
